﻿using System;
using Xamarin.Forms;

namespace Games.PegSolitaire
{
    class GameCell : Image
    {
        public static readonly ImageSource ImgChess = ImageSource.FromFile("ps_chess.png");
        public static readonly ImageSource ImgSelect = ImageSource.FromFile("ps_select.png");
        private bool hasChess;

        public event EventHandler Tapped;
        public GameCell()
        {
            Aspect = Aspect.Fill;
            TapGestureRecognizer tapGesture = new TapGestureRecognizer { NumberOfTapsRequired = 1 };
            tapGesture.Tapped += (sender, args) =>
            {
                Tapped?.Invoke(this, EventArgs.Empty);
            };
            GestureRecognizers.Add(tapGesture);
        }
        public int Col { set; get; }
        public int Row { set; get; }
        public bool HasChess
        {
            get => hasChess;
            set
            {
                hasChess = value;
                Source = hasChess ? ImgChess : null;
            }
        }
    }
}
